

package com.hazelcast.client.impl.protocol;

/**
 * Status codes of authentication results
 */
public enum AuthenticationStatus {

    AUTHENTICATED(0), CREDENTIALS_FAILED(1), SERIALIZATION_VERSION_MISMATCH(2), NOT_ALLOWED_IN_CLUSTER(3);

    private final byte id;

    AuthenticationStatus(int status) {
        this.id = (byte) status;
    }

    public static AuthenticationStatus getById(int id) {
        for (AuthenticationStatus as : values()) {
            if (as.getId() == id) {
                return as;
            }
        }
        throw new IllegalArgumentException("Unsupported ID value");
    }

    public byte getId() {
        return id;
    }
}
